﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace OPTFleet.OPTFleet
{
    public class Ponto2D
    {
        // instance variables - replace the example below with your own
        private Double x;
        private Double y;

        /**
         * Constructor for objects of class Ponto2D
         */
        public Ponto2D()
        {
            x = y = 0;
        }
        public Ponto2D(Double a, Double b)
        {
            x = a;
            y = b;
        }
        public Ponto2D(Ponto2D p)
        {
            x = p.GetX();
            y = p.GetY();
        }
        /** Methods */

        public Double GetX()
        {
            return x;
        }
        public Double GetY()
        {
            return y;
        }

        public void SetX(Double a)
        {
            x = a;
        }
        public void SetY(Double a)
        {
            y = a;
        }

        public void AddX(Double a)
        {
            x += a;
        }
        public void AddY(Double a)
        {
            y += a;
        }

        public override Boolean Equals(Object o)
        {
            if (o == null || o.GetType() != this.GetType()) return false;
            if (o == this) return true;
            Ponto2D p = (Ponto2D)o;
            return (p.GetX() == x && p.GetY() == y);
        }

        public override int GetHashCode()
        {
            return base.GetHashCode();
        }

        public override String ToString()
        {
            StringBuilder s = new StringBuilder();

            s.Append("Cord x é: ");
            s.Append(x);
            s.Append(" e a y é: ");
            s.Append(y);

            return s.ToString();
        }

        public Ponto2D Clone()
        {
            return (new Ponto2D(this));
        }
    }

}
